- 
                Notifications
    You must be signed in to change notification settings 
- Fork 41.6k
Exclude spring-boot-devtools from AOT processing in Maven #46533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude spring-boot-devtools from AOT processing in Maven #46533
Conversation
| @academey that's not strictly what we have in mind. Yes, remove devtools from the classpath that AOT considers to process the application, but also from the native image. This PR does the former, but not the latter. Would you be willing to amend it? There is some context in the linked issue. | 
| @snicoll Thank you for the feedback. After investigating further, I understand the issue better now. You're right. My current changes only exclude devtools from AOT processing but not from the native image itself. The issue is that while  From my analysis, I see a few potential approaches 
 Could you provide guidance on which approach would be most consistent with Spring Boot's design? I'm happy to implement the full solution once we agree on the direction. For reference, I believe the issue occurs because native-maven-plugin uses the raw classpath (as mentioned in the AOT docs), and devtools remains in that classpath even though it's excluded from AOT processing. | 
| I don't see the difference between 1 and 2. 2 is what I had in mind (at least trying) but it looks identical to 1. | 
| @snicoll You're right approaches 1 and 2 are the same. I was overthinking it I'll implement the solution by modifying the native profile in spring-boot-starter-parent to exclude devtools. This approach makes sense as it 
 I'll update the PR to include these changes. Thanks for the clarification | 
397d692    to
    e4af14b      
    Compare
  
    … Maven Previously, spring-boot-devtools was only excluded from native images built with Gradle but not with Maven. This inconsistency meant that Maven builds would include devtools in the AOT processing classpath and in the native image, causing build failures. This commit: - Applies DEVTOOLS_EXCLUDE_FILTER to the classpath during both main and test AOT processing in Maven plugin - Adds exclusions for devtools and docker-compose in the native-maven-plugin configuration within spring-boot-starter-parent - Ensures devtools is completely excluded from native images, not just from AOT processing The exclusion happens automatically without requiring any user configuration, ensuring that devtools is properly excluded from native images while maintaining its functionality during development. Fixes spring-projectsgh-32853 Signed-off-by: academey <[email protected]>
e4af14b    to
    d34f176      
    Compare
  
    | @snicoll I've updated the PR The changes now include 
 This ensures devtools is completely excluded from native images built with Maven, matching the Gradle behavior. The exclusions are applied automatically without requiring any user configuration. Please let me know if this approach looks good or if you'd like any adjustments! | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following-up. I am wondering about docker-compose being added in the parent + some nits.
| delegate.groupId('org.springframework.boot') | ||
| delegate.artifactId('spring-boot-devtools') | ||
| } | ||
| exclusion { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this? While I think this would be eventually useful, this feels like separate isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review!
I removed the docker-compose exclusions to keep this PR focused solely on devtools and also removed the verbose comments from the test methods. thanks.
        
          
                ...lugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AotTests.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                ...lugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AotTests.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      - Remove spring-boot-docker-compose exclusions as they are out of scope - Remove verbose comments from tests per Spring Boot conventions Signed-off-by: academey <[email protected]>
Previously, spring-boot-devtools was only excluded from native images built with Gradle but not with Maven. This inconsistency meant that Maven builds would include devtools in the AOT processing classpath and in the native image, causing build failures. This commit harmonizes the situation and excludes devtools in a similar fashion with Maven. See gh-46533 Signed-off-by: academey <[email protected]>
This PR ensures that spring-boot-devtools is excluded from AOT processing when building native images with Maven, matching the existing behavior in Gradle.
Problem:
When building native images with Maven, spring-boot-devtools remains on the classpath during AOT processing. This causes issues because devtools uses features incompatible with native images (like class proxies). In contrast, Gradle automatically excludes devtools through its
developmentOnlyconfiguration.Solution:
DEVTOOLS_EXCLUDE_FILTERto the classpath used during AOT processing in bothProcessAotMojoandProcessTestAotMojoTesting:
Fixes #32853